﻿using IdentityServer4.Models;
using System.Collections.Generic;

namespace AuhtorizationServer
{
  public static class IdentityServerConfig
  {

    /// <summary>
    /// Gets the clients.
    /// </summary>
    public static ICollection<Client> GetClients()
    {
      var clients = new List<Client>();
      var client = new Client
      {
        // 客户端id 用于标识客户端
        ClientId = "clientid",
        // 客户端秘密 验证客户端是否为真实的客户端
        ClientSecrets = new List<Secret>{
          new Secret("secret".Sha256())
        },
        // 允许客户端访问的范围
        AllowedScopes = new List<string> { "api1" },
        // 设置客户端授权模式
        AllowedGrantTypes = GrantTypes.ClientCredentials
      };
      clients.Add(client);
      return clients;
    }

    /// <summary>
    /// Gets the apis.
    /// </summary>
    public static ICollection<ApiResource> GetApis()
    {
      return new List<ApiResource> {
         new ApiResource("api1","IdentityServer4 客户端授权模式测试用API")
      };
    }
  }
}
